Conversation
…re/59787-merge-events
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
lan17
left a comment
There was a problem hiding this comment.
I think there are still two blockers before we merge this. I left inline notes on the partial sink integration and the unconditional reconstruction work on the evaluation hot path.
| ) | ||
|
|
||
|
|
||
| async def check_evaluation( |
There was a problem hiding this comment.
This still leaves the merged-event path only partially integrated across the public SDK surface. If a caller registers set_control_event_sink() but uses the public check_evaluation() helper, we just POST and return the parsed result without setting X-Agent-Control-Merge-Events or reconstructing/emitting any events. I think we need to either wire the sink behavior through this helper too, or explicitly scope the sink API away from this entry point.
There was a problem hiding this comment.
Good catch — you’re right. check_evaluation() currently bypasses the merged-event path even when a control event sink is registered, which makes the public SDK surface inconsistent. I think the right fix is to wire the sink behavior through this helper as well: when a sink is present, resolve trace/span IDs, send X-Agent-Control-Merge-Events: true, reconstruct the server events from the lightweight response plus cached control definitions, and emit them through the sink before returning the parsed result. That keeps the default behavior unchanged while making merged-event handling consistent across both public evaluation entry points.
There was a problem hiding this comment.
This comment is no longer valid. I have re-worked this PR to only contain merge model support
| local_control_lookup = { | ||
| control.id: control.control for control in applicable_local_controls | ||
| } | ||
| local_events = build_control_execution_events( |
There was a problem hiding this comment.
Can we avoid reconstructing events unless something will actually consume them? We now always build local events here, and we do the same for server events later, even when merged emission is off and even when OSS observability is disabled. Since evaluation is a latency-sensitive hot path, I don't think we should pay this parsing/allocation cost unless either the existing observability path is active or a merged-event sink is registered.
There was a problem hiding this comment.
I’m tightening the hot path so we only reconstruct events when they’ll actually be consumed: local events only when the default SDK observability path is enabled or a sink is registered, and server events only when the merged-event path is active.
Summary
Behavior
What changed
Testing